//package flyshoes.listener;
//
//import flyshoes.mybatis.entity.ShoppingCart;
//import flyshoes.mybatis.service.serviceImpl.ShoppingcartServiceImpl;
//import flyshoes.service.CartServiceImpl;
//import flyshoes.utils.ThreadLocalUtil;
//import lombok.RequiredArgsConstructor;
//import org.springframework.amqp.rabbit.annotation.Exchange;
//import org.springframework.amqp.rabbit.annotation.Queue;
//import org.springframework.amqp.rabbit.annotation.QueueBinding;
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
//import org.springframework.stereotype.Component;
//
//import java.util.List;
//
//@Component
//@RequiredArgsConstructor
//public class ClearProductListener {
//    private final CartServiceImpl cartService;
//    private final ShoppingcartServiceImpl cartDbService;
//    @RabbitListener(bindings = @QueueBinding(
//            value = @Queue(name = "order.create.success.queue",durable = "true"),
//            exchange = @Exchange(name = "order.direct"),
//            key = "order.create.success"
//    ))
//    public void clearProductListener(List<Integer> productIdList){
//        //System.out.println("类型是：------------------------------------------------"+(productIdList.get(0)).getClass().getSimpleName());
//        System.out.println("productLidt:-------------------------"+productIdList);
//        Integer userId = ThreadLocalUtil.get();
//        for (Integer productId : productIdList) {
//            boolean b = cartDbService.lambdaQuery()
//                    .eq(ShoppingCart::getUserId,userId)
//                    .eq(ShoppingCart::getProductId,productId)
//                    .exists();
//            if (b){
//                cartService.removeShoesInCart(productId);
//            }else {
//                System.out.println("此商品不在购物车");
//            }
//        }
//    }
//}
